#include <cstdio>
#include <cstring>
#include <algorithm>
#include <iostream>

using namespace std;
int t[200];

int main()
{
    int n;
	cin >> n;
    int x;
    long long sum = 1;
    int  tmp = -1;
    bool flag = false;
    for(int i=0;i<n;i++){
		cin >> x;
        if(x){
            if(flag==false){
                tmp = i;
            }else{
                sum *= i-tmp;
                tmp = i;
            }
            flag = true;

        }
    }
    if(flag){
		cout << sum << endl;
    }else{
        puts("0");
    }
    return 0;
}
